package entity_model.data_types;

import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import utils.titles.Title;

import java.io.IOException;

/**
 * Created by nuno-rafael-figueiredo on 02-07-2014.
 */
public abstract class DataType {
    protected DataType() {
        DataTypes.MAP.put(this.toString(), this);
    }

    @Override
    public String toString() {
        return Title.fromObject(this).toLowerCase();
    }

    public static class TypeAdapter extends com.google.gson.TypeAdapter<DataType>{
        @Override
        public void write(JsonWriter out, DataType value) throws IOException {
            if (value != null)
            out.value(value.toString());
        }

        @Override
        public DataType read(JsonReader in) throws IOException {
            return null;
        }
    }
}
